# 7-3 快乐的数字【分支循环】
import time

def is_happy_number(num):
    visited = set()
    while num != 1 and num not in visited:
        visited.add(num)
        num = sum(int(digit)**2 for digit in str(num))
    return num == 1

start_time = time.perf_counter()
number = int(input())
result = is_happy_number(number)
end_time = time.perf_counter()

if result:
    print("True")
else:
    print("False")

if end_time - start_time > 0.9:
    print("False")